<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>RVM : Unboxed Types</title>
        <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>

    <body>
        <div id="page">
            <div id="main">
                <div id="main-header" class="pageSectionHeader">
                    <h1 id="title-heading" class="pagetitle">
                                                <span id="title-text">
                            RVM : Unboxed Types
                        </span>
                    </h1>

                    <div class="page-metadata">
                        <p>This page last changed on Jul 03, 2008 by <font color="#0050B2">dgrove</font>.</p>
                    </div>
                </div>

                <div id="content" class="view">
                    <div id="main-content" class="wiki-content group">
                    <p>If a type is boxed then it means that values of that type are represented by a pointer to a heap object. An unboxed type is represented by the value itself such as int, double, float, byte etc. Values of unboxed types appear only in the virtual machine's stack, registers, or as fields/elements of class/array instances.</p>

<p>The Jikes RVM also defines a number of other unboxed types. Due to a limitation of the way the compiler generates code the Jikes RVM must define an unboxed array type for each unboxed type. The unboxed types are;</p>
<ul>
	<li>org.vmmagic.unboxed.Address</li>
	<li>org.vmmagic.unboxed.Extent</li>
	<li>org.vmmagic.unboxed.ObjectReference</li>
	<li>org.vmmagic.unboxed.Offset</li>
	<li>org.vmmagic.unboxed.Word</li>
	<li>org.jikesrvm.ArchitectureSpecific.Code</li>
</ul>


<p>Unboxed types may inherit from Object but they are not objects. As such there are some restrictions on the use of unboxed types:</p>
<ul>
	<li>A unboxed type instance must not be passed where an Object is expected. This will type-check, but it is not what you want. A corollary is to avoid overloading a method where the two overloaded versions of the method can only be distinguished by operating on an Object versus an unboxed type.</li>
	<li>An unboxed type must not be synchronized on.</li>
	<li>They have no virtual methods.</li>
	<li>They do not support lock operations, generating hashcodes or any other method inherited from Object.</li>
	<li>All methods must be compiler intrinsics.</li>
	<li>Avoid making an array of an unboxed type. Instead represent it by the array version of unboxed type. i.e. <code>org.vmmagic.unboxed.Address[]</code> should  be replaced with <code>org.vmmagic.unboxed.AddressArray</code> but <code>org.vmmagic.unboxed.AddressArray[]</code> is fine.</li>
</ul>
                    </div>

                    
                 
                </div>             </div> 
            <div id="footer" style="background: url(http://docs.codehaus.org/images/border/border_bottom.gif) repeat-x;">
                <p><small>Document generated by Confluence on Feb 17, 2012 10:24</small></p>
            </div>
        </div>     </body>
</html>
